package com.luoying.itew.factory;

import androidx.fragment.app.Fragment;

import com.luoying.itew.fragment.ChartsFragment;
import com.luoying.itew.fragment.ChartsWeatherFragment;
import com.luoying.itew.fragment.CollectorFragment;
import com.luoying.itew.fragment.DetailsFragment;
import com.luoying.itew.fragment.InspectLogFragment;


/**
 * Created by Administrator on 2017/5/22.
 */
public class FragmentFactory {
    private static final int FRAGMENT_DETAILS= 0;
    private static final int FRAGMENT_CHARTS = 1;
//    private static final int FRAGMENT_CHARTS_HOUR= 2;
private static final int FRAGMENT_WEATHER = 2;
    private static final int FRAGMENT_COLLECTOR = 3;
    private static final int FRAGMENT_INSPECT_LOG = 4;
    private static FragmentFactory sFragmentFactory;

    public static FragmentFactory getInstance(){
        if (sFragmentFactory == null){
            synchronized (FragmentFactory.class){
                if (sFragmentFactory == null){
                    sFragmentFactory = new FragmentFactory();
                }
            }
        }
        return sFragmentFactory;
    }
    public Fragment getFragment(int position) {
        switch (position) {
            case FRAGMENT_DETAILS:  //监测点详情
                return new DetailsFragment();
            case FRAGMENT_CHARTS:   //统计图表
                return new ChartsFragment();
//            case FRAGMENT_CHARTS_HOUR:   //位移时表
//                return new ChartsHourFragment();
            case FRAGMENT_COLLECTOR:    //采集器
                return new CollectorFragment();
            case FRAGMENT_INSPECT_LOG:  //巡查日志
                return new InspectLogFragment();
            case FRAGMENT_WEATHER:  //天气图表
                return new ChartsWeatherFragment();
        }
        return null;
    }
}
